/*****************************************************************************************************************************
 * \file   : Queue.h   
 * \module : Queue 
 * \brief  : Queue process head file  
 * \project: 
 * \author : SHB
 *============================================================================================================================
 *                                                   Revision control History
 *============================================================================================================================
 * V1.0.0: 2021-06-29: Initial Version
 *
 *
 *
 ****************************************************************************************************************************/
#ifndef QUEUE_H
#define QUEUE_H

/*****************************************************************************************************************************
 * Other header files
 ****************************************************************************************************************************/
#include "stdint.h"


/*****************************************************************************************************************************
 * Macro decalaration
 ****************************************************************************************************************************/
#define QUEUE_SIZE      	(8U)
/*****************************************************************************************************************************
 * Enum decalaration
 ****************************************************************************************************************************/


/*****************************************************************************************************************************
 * union decalaration
 ****************************************************************************************************************************/


/*****************************************************************************************************************************
 * typedef compound type decalaration
 ****************************************************************************************************************************/
typedef uint16_t Queue_DataType;
/*****************************************************************************************************************************
 * Struct decalaration
 ****************************************************************************************************************************/
typedef struct {
    uint8_t Qhead;
    uint8_t Qtail;
    uint8_t Qsize;
    uint8_t Qused;
    Queue_DataType Qbuf[QUEUE_SIZE];
} Queue;

/*****************************************************************************************************************************
 * Global variable decalaration
 ****************************************************************************************************************************/


/*****************************************************************************************************************************
 * Global function declaration prototype 
 ****************************************************************************************************************************/
/*!
 * \brief Queue class Constructor function
 * \param[in] me - Queue pointer
 * \param[in] QueSize - Queue size
 * \return void
 */
extern void Queue_Ctor(Queue *me, uint8_t QueSize);
/*!
 * \brief Queue pop function
 * \param[in] me - Queue pointer
 * \return The data in bottom of the queue
 * \note Makesure that the queue is not empty before call it.
 */
extern Queue_DataType Queue_Pop(Queue *me);
/*!
 * \brief Queue push function
 * \param[in] me - Queue pointer
 * \param[in] Qdata - Data to be written to the queue
 * \return void
 * \note Makesure that the queue is not full before call it.
 */
extern void Queue_Push(Queue *me, Queue_DataType Qdata);
/*!
 * \brief Check Queue is full
 * \param[in] me - Queue pointer
 * \retval TRUE - Queue is full
 *         FALSE - Queue is not full
 */
extern uint8_t Queue_IsFull(Queue *me);
/*!
 * \brief Check Queue is empty
 * \param[in] me - Queue pointer
 * \retval TRUE - Queue is empty
 *         FALSE - Queue is not empty
 */
extern uint8_t Queue_IsEmpty(Queue *me);
/*!
 * \brief Clear Queue
 * \param[in] me - Queue pointer
 * \return void
 */
extern void Queue_Clear(Queue *me);
#endif
/*****************************************************************************************************************************
 * End of file
 ****************************************************************************************************************************/

